package com.jerome.fs.util;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Thread factory class
 * @author Jerome
 * @date 2023/9/9
 */
public class ThreadPoolFactory implements ThreadFactory {
    private AtomicInteger threadNumber = new AtomicInteger(1);

    private String prefix = null;

    public ThreadPoolFactory(String prefix) {
        super();
        this.prefix = prefix;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public Thread newThread(Runnable r) {
        return new Thread(r, prefix + threadNumber.getAndIncrement());
    }

}